from fastapi import FastAPI
from loguru import logger

# log_path = '/data/logs/management/app.log'
from python.api.speech_to_text import to_text

log_path = '/data/logs/management/app_{time:YYYYMMDD}.log'
logger.add(log_path, format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}", filter="app", level="DEBUG", rotation="10 MB", retention='7 days', compression='zip', encoding='utf-8')
app = FastAPI()

@app.get("/speech/to/text")
def stt(file_path: str):
    logger.info('Enter method speech to text and the param file_path is {}', file_path)
    return to_text(file_path)
